﻿@functions
{
    bool ShouldShow(ModelMetadata metadata)
    {
        return metadata.ShowForEdit
               && !ViewData.TemplateInfo.Visited(metadata);
    }
}

    @foreach (ModelMetadata prop in ViewData.ModelMetadata.Properties.Where(ShouldShow))
    {
        if (prop.HideSurroundingHtml || prop.TemplateHint == "hidden")
        {
            @Html.Editor(prop.PropertyName)
        }
        else
        {
            <div>
                <label for="@ViewData.TemplateInfo.GetFullHtmlFieldId(prop.PropertyName)" @if(prop.IsRequired){<text>class = "required"</text>}>@(prop.DisplayName??prop.PropertyName):</label>
                @Html.Editor(prop.PropertyName)
            </div>
        }
    }